package com.javabasic.cglib;

import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.InvocationHandler;

import java.lang.reflect.Method;

/**
 * @author: 晓帆
 * @description:
 * @create: 2021-06-24 19:51
 **/
public class CglibDemo {

    public static void main(String[] args) {
        UserService1 userService = new UserServiceImp1();
        UserServiceImp1 o = (UserServiceImp1)Enhancer.create(UserServiceImp1.class, new InvocationHandler() {
            @Override
            public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
                Object invoke = method.invoke(userService, objects);
                invoke=invoke+"sasa";
                return null;
            }
        });
        String nihao = o.say("nihao");
        System.out.println(nihao);

    }
}
